<meta charset="utf-8" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> 
<form action="change_club.php" method="POST" name="frmdo" id="frmdo" target="_self">
<?php
$club_number=$_REQUEST['idclub'];
include "db.php";
$sql2="SELECT * FROM st_club WHERE club_number='$club_number'"; 
$valor2 = mysql_query($sql2) or die ("error en consulta");
$distri=mysql_result($valor2,0,'district'); $area=mysql_result($valor2,0,'areas'); $div=mysql_result($valor2,0,'division'); 
$cnum=mysql_result($valor2,0,'club_number'); $cname=mysql_result($valor2,0,'club_name');$cdate=mysql_result($valor2,0,'charter_date');
$add1=mysql_result($valor2,0,'address1'); $add2=mysql_result($valor2,0,'address2');$ciud=mysql_result($valor2,0,'city'); 
$estado=mysql_result($valor2,0,'estado_id');$codp=mysql_result($valor2,0,'cp'); $pais=mysql_result($valor2,0,'country');
$tel=mysql_result($valor2,0,'phone'); $mt=mysql_result($valor2,0,'meeting_time');$md=mysql_result($valor2,0,'meeting_day'); 
$mt=mysql_result($valor2,0,'meeting_time'); $cst=mysql_result($valor2,0,'club_status'); $cwsite=mysql_result($valor2,0,'club_website');
$cemail=mysql_result($valor2,0,'club_email'); $face=mysql_result($valor2,0,'facebook');$adv=mysql_result($valor2,0,'advance'); 
$satatu=mysql_result($valor2,0,'statuss');$dateact=mysql_result($valor2,0,'date_activacion');
echo "<table align='center' border=''>
	<tbody>
		<tr>
			<td>Número de Club:</td>
			<td><input type='text' name='c_number' value='$cnum' readonly></td>
		</tr>
		<tr>
			<td>Distrito:</td>
			<td><input type='text' name='distri' value='$distri' required></td>
		</tr>
		<tr>
			<td>Area:</td>
			<td><input type='text' name='area' value='$area' required></td>
		</tr>
		<tr>
			<td>Division:</td>
			<td><input type='text' name='division' value='$div' required></td>
		</tr>
		<tr>
			<td>Nombre del Club:</td>
			<td><input type='text' name='c_name' value='$cname' required></td>
		</tr>
		<tr>
			<td>Charter Date:</td>
			<td><input type='text' name='c_d' value='$cdate'></td>
		</tr>
		<tr>
			<td>Dirección 1:</td>
			<td><input type='text' name='add1' value='$add1'></td>
		</tr>
		<tr>
			<td>Dirección 2:</td>
			<td><input type='text' name='add2' value='$add2'></td>
		</tr>
		<tr>
			<td>Ciudad:</td>
			<td><input type='text' name='cuidad' value='$ciud' required></td>
		</tr>
		<tr>
			<td>Estado:</td>
			<td>
			<select name = 'estado'>";
				$query="SELECT * FROM st_estados order by nombre";
				$result_query =mysql_query($query);	
				$cuantos=mysql_num_rows($result_query);
				$sql="SELECT nombre FROM st_estados WHERE estado_id='$estado'";
				$valor = mysql_query($sql) or die ("$sql");
				$nestado= mysql_result($valor,0,'nombre');
				echo"<option value='$estado'>$nestado</option>";
				for( $y=0;$y<$cuantos;$y++)
				{
					$id_estado=mysql_result($result_query,$y,'id_area');
					$nameestado=mysql_result($result_query,$y,'nombre');
					echo"<option value='$id_estado'>$nameestado</option>";
				}
	echo  "</select>
			
			</td>
		</tr>
		<tr>
			<td>Codigo Postal:</td>
			<td><input type='text' name='cp' value='$codp' required></td>
		</tr>
		<tr>
			<td>Pais:</td>
			<td><input type='text' name='pais' value='$pais' required></td>
		</tr>
		<tr>
			<td>Telefono:</td>
			<td><input type='text' name='tel' value='$tel'></td>
		</tr>
		<tr>
			<td>Hora de Reunión:</td>
			<td><input type='text' name='mt' value='$mt'></td>
		</tr>
		<tr>
			<td>Día de Reunión:</td>
			<td><input type='text' name='md' value='$md'></td>
		</tr>
		<tr>
			<td>Status del Club:</td>
			<td><input type='text' name='cs' value='$cst'></td>
		</tr>
		<tr>
			<td>Sitio Web del Club:</td>
			<td><input type='text' name='cws' value='$cwsite'></td>
		</tr>
		<tr>
			<td>Email del Club:</td>
			<td><input type='text' name='cem' value='$cemail'></td>
		</tr>
		<tr>
			<td>Facebook:</td>
			<td><input type='text' name='face' value='$face'></td>
		</tr>
		<tr>
			<td>Advance</td>
			<td><input type='text' name='adv' value='$adv'></td>
		</tr>
		<tr>
			<td>Status</td>
			<td>";
			if ($satatu=='i'){
			echo "<select name='statuss'><option value='i'>Inactivo</option><option value='a'>Activo</option></select>";
			} else {
			echo "<select name='statuss'><option value='a'>Activo</option><option value='i'>Inactivo</option></select>";
			}
echo"	</td>
		</tr>
	</tbody>
</table>";
?>
<center><input name='guardar' type='submit' value='Agregar Club'/>
<div id="ajax3"></div></center>
</form>
 <script type='text/javascript'>
$(function (e) {
	$('#frmdo').submit(function (e) {
		e.preventDefault()
		$('#ajax3').load('change_club2.php?'+ $('#frmdo').serialize())
	})
})
</script>